package images;

import java.io.File;
import java.io.IOException;
import java.awt.image.BufferedImage;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import javax.swing.JFrame;

public class APImageFrame extends JFrame {
   
    /**
     * This constructor creates a frame to view an image which
     * is read from a file.
     * 
     * @param file The file object which specifies the image file on disk to load and view.
     * @throws IOException Thrown if there is an error loading the image from disk.
     */
    public APImageFrame() throws IOException {
        File file = new File("smallHalfDome.jpg");
        setTitle(file.getName());
        BufferedImage image = APImage.getImageFromFile(file);
        APImagePanel imagePanel = new APImagePanel(image);
        Container c = getContentPane();
        c.setBackground(Color.white);
        c.add(imagePanel, BorderLayout.CENTER);
        pack();
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
    }

}
